package org.outerj.daisy.diff.html.dom;


import java.util.IdentityHashMap;
import org.xml.sax.Attributes;

public class TagNodeProduct {
	private IdentityHashMap<Attributes, Boolean> attributesEqualityTests = new IdentityHashMap<Attributes, Boolean>();

	public IdentityHashMap<Attributes, Boolean> getAttributesEqualityTests() {
		return attributesEqualityTests;
	}

	public void setAttributesEqualityTests(
			IdentityHashMap<Attributes, Boolean> attributesEqualityTests) {
		this.attributesEqualityTests = attributesEqualityTests;
	}

	public boolean hasSameAttributes(final Attributes otherAttributes,
			TagNode tagNode) {
		if (otherAttributes == null) {
			return false;
		}
		if (attributesEqualityTests.get(otherAttributes) != null) {
			return attributesEqualityTests.get(otherAttributes);
		}
		boolean result = tagNode.getAttributesMap().hasSameAttributes(
				otherAttributes);
		attributesEqualityTests.put(otherAttributes, result);
		return result;
	}
}